<script src="/assets/js/jquery.bootbox.min.js"></script>
<script src="/b/<%=branch%>/proxy/config?key=item,unit,chip,egg,box,itemGroup,unitBase,igroup,gem,MsgList,"></script>
<script src="/assets/item.js"></script>

<script>
    function defaultAfterShowForm(e,edit){
//        $("#uid").css({width:500});
//        $("#title").css({width:500});
//        $("#attr").css({width:500});
        $("#uid").attr("title","不能为空,多个用户','分割'").tooltip({container:'body'});
        cosjs.jqgrid.timeMask($("#btime"));
        cosjs.jqgrid.timeMask($("#time"));
    }


    var status_list = {0:"未读",1:"已读[附件未领]",2:"已读[附件已领]",9:"已删除"};
    var option = {
        url : GURL(handle, 'page?sid='+sid+'&api=/'+api+'/page'),
        editurl :GURL(handle,'save?sid='+sid+'&api=/'+api+'/save'),
        colModel : [
            {label: 'id', name: '_id',key:true,width: 200,editable: false, hidden:false,fixed:true,search:false},

            {label: 'uid', name: 'uid',width: 180,editable: true, hidden:false,fixed:true,search:true,
                searchoptions:{sopt:['eq']}
            },

            {label: 'title', name: 'title',width: 300, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false},

            {label: 'status', name: 'status',width: 120, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:'select', edittype:'select', editoptions:{ value:status_list },
            },
            {label: 'btime', name: 'btime',width: 150, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:cosjs.jqgrid.timeFormat,
            },
            {label: 'time', name: 'time',width: 150, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:cosjs.jqgrid.timeFormat,
            },
            {label: 'attr', name: 'attr',width: 280, editable: true, sortable:false,hidden:false,resize:false,fixed:true,search:false,
                formatter:cosjs.item.formatter,
                unformat:cosjs.item.unformat,
                editoptions: { dataInit: function (element) { new cosjs.item.select(element); } }
            },
            {label: 'content', name: 'content',width: 280, editable: true, sortable:false,hidden:false,resize:false,fixed:false,search:false,
                edittype:'textarea',editoptions:{rows:"8",cols:"70"},
            },

        ],
        afterShowAddForm : function(e){
            defaultAfterShowForm(e,0);
        },
        afterShowEditForm : function(e){
            defaultAfterShowForm(e,1);
        },
    }
    $(document).ready(function () {
        cosjs.jqgrid.create(grid_selector,pager_selector,option,{add:true,edit:true,search:true});
    });
</script>
